package pers.gxm.abstractfactory.listfactory;

import pers.gxm.abstractfactory.factory.Item;
import pers.gxm.abstractfactory.factory.Tray;

import java.util.Iterator;

public class ListTray extends Tray {
    public ListTray(String caption){
        super(caption);
    }
    @Override
    public String makeHTML() {
        StringBuffer sb = new StringBuffer();
//        sb.append("<ul>\n");
        addTab(sb);
        sb.append("<li>");
        sb.append(caption+"\n");
        addTab(sb);
        sb.append("\t<ul>\n");
        Iterator<Item> it = tray.iterator();
        while (it.hasNext()){
            Item item = it.next();
            sb.append(item.makeHTML());
        }
        addTab(sb);
        sb.append("\t</ul>\n");
        addTab(sb);
        sb.append("</li>\n");
//        sb.append("</ul>\n");
        return sb.toString();
    }




}
